#pragma warning disable 0618
using System;
using System.Collections.Generic;
using Table.DataModel;
namespace Table.Dao
{
    public class TableSkillLineDao:DaoBase<TableSkillLine>
    {
        public override string GetFileName()
        {
            return "TableSkillLine.csv";
        }
        public override void BuildIndex()
        {
            if (cacheList != null)
            {
                cachePrimaryInt = new Dictionary<int, TableSkillLine>(cacheList.Count);
            }
            base.BuildIndex();
        }
        public override void AddOneIndex(TableSkillLine model)
        {
            if (!cacheOneIndex.ContainsKey(model.heroId.ToString()))
            {
                cacheOneIndex[model.heroId.ToString()] = new List<TableSkillLine>();
            }
            cacheOneIndex[model.heroId.ToString()].Add(model);
        }
        public override void AddPrimaryIndex(TableSkillLine model)
        {
            #if UNITY_EDITOR
            if(cachePrimaryInt.ContainsKey(model.lineId)) UnityEngine.Debug.LogError("数据表id重复:TableSkillLine->id: " + model.lineId);
            #endif
            cachePrimaryInt[model.lineId] = model;
        }
        protected override TableSkillLine ParseRowData(string[] rowData)
        {
            TableSkillLine data = new TableSkillLine();
            if (!string.IsNullOrEmpty(rowData[0]))
            {
                data.lineId = int.Parse(rowData[0]);
            }
            if (!string.IsNullOrEmpty(rowData[1]))
            {
                data.heroId = int.Parse(rowData[1]);
            }
            if (!string.IsNullOrEmpty(rowData[2]))
            {
                data.fromRow = int.Parse(rowData[2]);
            }
            if (!string.IsNullOrEmpty(rowData[3]))
            {
                data.fromCol = int.Parse(rowData[3]);
            }
            if (!string.IsNullOrEmpty(rowData[4]))
            {
                data.toRow = int.Parse(rowData[4]);
            }
            if (!string.IsNullOrEmpty(rowData[5]))
            {
                data.toCol = int.Parse(rowData[5]);
            }
            if (!string.IsNullOrEmpty(rowData[6]))
            {
                data.toSkillId = ParseData<int>(rowData[6]);
            }
            if (!string.IsNullOrEmpty(rowData[7]))
            {
                data.targetType = int.Parse(rowData[7]);
            }
            return data;
        }
    }
}
